import java.util.Scanner;

/**
 * @description: 使用for循环解决阶乘问题
 * @author: WangBlue
 * @create: 2023-10-23 21:28
 **/
public class FactorialByFor {
    public static void main(String[] args) {
        System.out.println("请输入你想要阶乘的数字：");
        int number = new Scanner(System.in).nextInt();
        int result = 1;

        if (number < 0){
            System.out.println("输入的数字有误");
            return;
        }else if (number == 0){
            System.out.println("0的阶乘为1");
            return;
        }
        for (; number>0; number-- ) {
            result *= number;
        }

        System.out.println("结果为：" + result);

    }


}
